<#import '/ftlLibrary/properteisVariable.ftl' as pv/>
<link href="assets/css/bootstrap-select.css" rel="stylesheet"/>
<link href="assets/css/front/listCommonStyle.css" rel="stylesheet"/>
<link href="assets/css/modify.css" rel="stylesheet"/>
<script src="assets/js/select2/select2.js"></script>
<style>
    .businessBtns .btn {
        margin-right: 0px!important;
    }
</style>
<div class="row margin-left-10">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <div class="widget flat margin-top-0" style="margin: -10px 0 0px 0!important;">
            <div class="widget-header bordered-sky theme-bordered nopadding">
                <div class="widget-buttons widget-label nomargin-bottom">
                    <label class="businessBtns">
                        <ol class="breadcrumb" style="margin: 0;">
                            <li style="color: #809fa6;">审批管理</li>
                            <li class="active" style="color: #23a8f5;">审批列表</li>
                        </ol>
                    </label>
                </div>
            </div>
        </div>
    </div>

    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12  nopadding-right">
        <div class="widget flat searchCriteria margin-top-0" style="margin: 3px 0 0px 0!important;">
            <div class="widget-header bordered-sky theme-bordered nopadding">
                <div class="widget-buttons widget-label" style="margin-bottom: 10px!important;">
                    <label class="businessBtns">
                        <label class="margin-right-20">
                            <a style="border-radius: 0px;border: none;background: #23a8f5 !important;"
                               class="btn btn-blue shiny download"
                               onclick="exportData('${searchFormId}','MemberInformation.xlsx')"><i
                                    class="fa fa-share"></i>导出
                            </a>
                        </label>
                        <label class="margin-right-20">
                            <a style="border-radius: 0px;border: none;background: #ffab00 !important;"
                               class="btn btn-warning shiny search "><i class="fa fa-search"></i>搜索
                            </a>
                        </label>
                        <label onclick="iconsChange()" style="margin-right: 6px">
                            <label>
                                <a class="iconsChangeA"
                                   style="width: 13px;height: 13px;cursor: pointer;background: url('assets/img/nav-img/icon_hidden.png');display: block;-webkit-user-select:none; -moz-user-select:none; -ms-user-select:none;user-select:none;"
                                   value="1"></a>
                            </label>
                            <label style="color: #23a8f5 ;vertical-align: middle;padding-top:4px;">
                                <span class="iconsChangeSpan"
                                      style="-webkit-user-select:none; cursor: pointer;-moz-user-select:none; -ms-user-select:none;user-select:none;">隐藏搜索栏</span>
                            </label>
                        </label>
                    </label>
                </div>
            </div>
        </div>

        <div class="search_Bar" style="vertical-align: middle">
            <form id="${searchFormId}" action="${actionUrl}" class="searchConditions" method="POST">
                <input type="hidden" id="cg">
                <div class="row searchInput" style="margin: 0;">
                    <label class="iconchange1 hidden" style="position: absolute;right: 10px;top: 0px;" >
                        <a class="search_Bar_A" id="iconchangemore" style="color: #2a6496;cursor: pointer;" onclick="iconchangeShow(this)" value="1">筛选更多<i class="fa fa-chevron-down" style="padding-left: 5px"></i></a>
                    </label>
                    <label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
                        <label style="width: 78px">会员姓名：</label>
                        <label>
                            <input type="text" name="name" value="${search_map.name[0]}"
                                   style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;">
                        </label>
                    </label>
                    <label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
                        <label style="width: 78px">会员昵称：</label>
                        <label>
                            <input type="text" name="nickName" value="${search_map.nickName[0]}"
                                   style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;" placeholder="未实现">
                        </label>
                    </label>
                    <label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
                        <label style="width: 78px">联系电话：</label>
                        <label>
                            <input type="text" name="contactPhone" value="${search_map.contactPhone[0]}"
                                   style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;">
                        </label>
                    </label>
                    <label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
                        <label style="width: 78px">审核状态(未实现)：</label>
                        <label>
                            <input type="text" name="refundStatus" value="${search_map.refundStatus[0]}"
                                   style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;">
                        </label>
                    </label>
                    <label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
                        <label style="width: 78px">申请日期：</label>
                        <label>
                            <input type="text" id="d4311" name="createTime_begin" class="beginValue Wdate" value="${search_map.createTime_begin[0]}" style="width: 90px;height: 30px!important;padding-left:3px!important;border: 1px solid #c6d5d8;border-radius: 4px !important;" onfocus="WdatePicker({doubleCalendar:true,maxDate:'#F{$dp.$D(\'d4312\')}',dateFmt:'yyyy-MM-dd'})"> 至
                            <input id="d4312" type="text" name="createTime_end" class="endValue Wdate" value="${search_map.createTime_end[0]}" style="width: 90px;height: 30px!important;padding-left:3px!important;border: 1px solid #c6d5d8;border-radius: 4px !important;" onfocus="WdatePicker({doubleCalendar:true,minDate:'#F{$dp.$D(\'d4311\')}',dateFmt:'yyyy-MM-dd '})">
                        </label>
                    </label>
                    <label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
                        <label style="width: 78px">退款日期：</label>
                        <label>
                            <input type="text" id="d4313" name="updateTime_begin" class="beginValue Wdate" value="${search_map.updateTime_begin[0]}" style="width: 90px;height: 30px!important;padding-left:3px!important;border: 1px solid #c6d5d8;border-radius: 4px !important;" onfocus="WdatePicker({doubleCalendar:true,maxDate:'#F{$dp.$D(\'d4314\')}',dateFmt:'yyyy-MM-dd'})"> 至
                            <input id="d4314" type="text" name="updateTime_end" class="endValue Wdate" value="${search_map.updateTime_end[0]}" style="width: 90px;height: 30px!important;padding-left:3px!important;border: 1px solid #c6d5d8;border-radius: 4px !important;" onfocus="WdatePicker({doubleCalendar:true,minDate:'#F{$dp.$D(\'d4313\')}',dateFmt:'yyyy-MM-dd '})">
                        </label>
                    </label>
                    <label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
                        <label style="width: 78px">退费类型：</label>
                        <label>
                            <select class="form-select-1" style="width: 90px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;padding-left: 0px!important;padding-right: 0px!important;" name="refundType" >
                                <@dictionary groupCode="refundType";dics>
                                <#list dics as dic>
                                <option value="${dic.code}">${dic.value}</option>
                            </#list>
                        </@dictionary>
                        </select>
                        </label>
                    </label>
                </div>
            </form>
        </div>
    </div>
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <div class="widget flat radius-bordered" style="margin-top: 0;box-shadow:0px 0px 10px rgba(122,161,184,0.3);">
            <div class="widget-body no-padding ">
                <div class="topPagingBar hidden">
                    ${pagingBar}
                </div>
                <div class="table-scrollable" style="border: none;">
                    <table class="table table-hover dataTable newtable ">
                        <thead>
                        <tr>
                            <th title="选择" class="checkboxColumnTh  ">
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" class="chkAll">
                                        <span class="text"></span>
                                    </label>
                                </div>
                            </th>
                            <th title="属性名">序号</th>
                            <th title="操作项">操作项</th>
                            <th title="会员姓名">会员姓名</th>
                            <th title="联系电话">联系电话</th>
                            <th title="报名状态">报名状态</th>
                            <th title="费用金额">费用金额</th>
                            <th title="退费类型">退费类型</th>
                            <th title="退费金额">退费金额</th>
                            <th title="审核状态">审核状态</th>
                            <th title="申请人">申请人</th>
                            <th title="审核人">审核人</th>
                            <th title="申请时间">申请日期</th>
                            <th title="操作时间">退费日期</th>
                        </tr>
                        </thead>
                        <tbody id="tableScrollableApprovalList">
                        <#if page_bean.list?size==0>
                            <tr>
                                <td align="center">无数据</td>
                            </tr>
                        </#if>
                        <#list page_bean.list as data>
                            <tr>
                                <td class="checkboxColumnTd">
                                    <div class="checkbox">
                                        <label>
                                            <input type="checkbox" class="chk" name="chk" value="${data.id}">
                                            <span class="text"></span>
                                        </label>
                                    </div>
                                </td>
                                <td>${data_index+1+(page_bean.pageNo-1)*page_bean.pageSize}</td>
                                <td>
                                    <!--<a href="javascript:void(0)"  onclick="Approval(this)" stuId="${data.stuId}"
                                       packageId="${data.packageId}"refundId="${data.id}" paymentId="${data.paymentId}"
                                       refundStatus="${data.refundStatus}"refundType="${data.refundType}"></a>-->
                                    <#if data.refundStatus==2>
                                    <@hp code="SPLB5167295130374-list_approval" params="[stuId=${data.stuId},packageId=${data.packageId},refundId=${data.id},paymentId=${data.paymentId},refundStatus=${data.refundStatus},refundType=${data.refundType}]" />
                                    </#if>
                                    <#if data.refundStatus==3>
                                    <@hp code="SPLB5167295130374-list_confirm" params="[stuId=${data.stuId},packageId=${data.packageId},refundId=${data.id},paymentId=${data.paymentId},refundStatus=${data.refundStatus},refundType=${data.refundType}]" />
                                    </#if>
                                    <#if data.refundStatus==4>
                                    <@hp code="SPLB5167295130374-list_change" params="[stuId=${data.stuId},packageId=${data.packageId},refundId=${data.id},paymentId=${data.paymentId},refundStatus=${data.refundStatus},refundType=${data.refundType}]" />
                                    </#if>
                                </td>
                                <td> <a href="javascript:void(0)"  stuId="${data.stuId}" class="ApprovalTd"
                                        packageId="${data.packageId}"refundId="${data.id}" paymentId="${data.paymentId}"
                                        refundStatus="${data.refundStatus}"refundType="${data.refundType}" flag="1">
                                    ${(data.name???string(data.name?html,"未设置"))!'未设置'}</a></td>
                                <!--<td>${(data.name???string(data.name?html,"未设置"))!'未设置'}</td>-->
                                <td>${(data.contactPhone???string(data.contactPhone?html,"未设置"))!'未设置'}</td>
                                <td> <@dictionary groupCode="applyStatus" dictionaryCode="${data.applyStatus}" ;applyStatus>${applyStatus.value }</@dictionary></td>
                                <td>${(data.sumAmout???string(data.sumAmout?html,"未设置"))!'未设置'}</td>
                                <!--<td> <@dictionary groupCode="refundType" dictionaryCode="${data.refundType}" ;refundType>${refundType.value }</@dictionary></td>-->
                                <td>${(data.refundType???string(data.refundType?html,"未设置"))!'未设置'}</td>
                                <td>${(data.returnAmout???string(data.returnAmout?html,"未设置"))!'未设置'}</td>
                                <td>${(data.refundStatus???string(data.refundStatus?html,"未设置"))!'未设置'}</td>
                                <td>${(data.createName???string(data.createName?html,"未设置"))!'未设置'}</td>
                                <td>${(data.userName???string(data.userName?html,"未设置"))!'未设置'}</td>
                                <td>${(data.createTime???string(data.createTime?html,"未设置"))!'未设置'}</td>
                                <td>${(data.updateTime???string(data.updateTime?html,"未设置"))!'未设置'}</td>
                            </tr>
                        </#list>
                        </tbody>
                    </table>
                </div>
                ${pagingBar}
            </div>
        </div>
    </div>
</div>
<script>
    $(".selectpicker").select2();
    /**
     * 新增缴费
     * @param that
     */
    function addPayment(that) {
        var user = "1";
        ajaxRequest("tssPaymentController/toAddedPaymentView.do", {
            user:user
        }, function (html) {
            getTopWin().bootbox.dialog({
                message: html,
                title: "定金",
                className: 'myDialog '
            });
        }, function () {
            ajaxError("加载页面失败!")
        }, "get", "html")
    }

    /**
     * 审批
     * @param that
     * @constructor
     */
    $("#tableScrollableApprovalList").on("click",".ApprovalTd",function () {
        var stuId = $(this).attr("stuId");
        var refundId = $(this).attr("refundId");
        var refundStatus = $(this).attr("refundStatus");
        var refundType = $(this).attr("refundType");
        var packageId = $(this).attr("packageId");
        var paymentId = $(this).attr("paymentId");
        var flag = $(this).attr("flag");
        console.log(flag);
        ajaxRequest("tssMemberReturnPremiumController/toApprovalOperation.do", {
            stuId:stuId,
            packageId:packageId,
            refundId:refundId,
            refundType:refundType,
            refundStatus:refundStatus,
            paymentId:paymentId,
            flag:flag
        }, function (html) {
            getTopWin().bootbox.dialog({
                message: html,
                title: "退费审核",
                className: 'myDialog familyMemberDialog',
            });
            $(".modal-header").find(".bootbox-close-button").removeClass("close");
            $(".modal-header").find(".bootbox-close-button").html("");
        }, function () {
            ajaxError("加载页面失败!")
        }, "post", "html")
    })

    /**
     * 导出数据
     * @param formId 条件表单id
     * @param templateName 导出的文件名
     */
    function exportData(formId, templateName) {
        var params = $("#" + formId).serialize();
        var exportIframe = ' <iframe class="hidden" id="exportIframe" name="exportIframe"></iframe>';
        var exportSrc ="tssMemberReturnPremiumController/exportExcle.do";
        var $exportForm = $('<form method="post" target="exportIframe" action="' + exportSrc + '" id="exportForm"></form>');
        $("#" + formId).find("input").map(function (i, input) {
            var $input = $(input);
            var name = $input.attr("name");
            var val = $input.val();
            if (name) {
                $exportForm.append('<input type="hidden" name="' + name + '" value="' + val + '">');
            }
        });

        //追加参数
        $exportForm.append('<input type="hidden" name="templateName" value="' + templateName + '">');
        $exportForm.append('<input type="hidden" name="loginAdminUserId" value="${loginUserId}">');

        /**
         * 定义标识
         * @param flag:代表有无条件参数
         * */
        var flag = 0;

        $exportForm.append('<input type="hidden" name="flag" value='+flag+'>');

        //删除并提交表单
        $("body #exportIframe").remove();
        $("body #exportForm").remove();
        $("body").append(exportIframe);
        $("body").append($exportForm);
        $exportForm.submit();
    };
    //    隐藏显示搜索
    function iconsChange() {
        if($(".iconsChangeA").val()==1){
            $(".iconsChangeA").val("0");
            $(".iconsChangeA").css("background","url('assets/img/nav-img/icon_hidden.png')");
            $(".iconsChangeSpan").html("隐藏搜索栏");
            $(".search_Bar").removeClass("hidden");
        }else{
            $(".iconsChangeA").val("1");
            $(".iconsChangeA").css("background","url('assets/img/nav-img/icon_show.png')");
            $(".iconsChangeSpan").html("显示搜索栏");
            $(".search_Bar").addClass("hidden");
        }
    }

    //    筛选下拉框
    setTimeout(function () {
        var size = $(".search_Bar_item").size();
        if (size > 8) {
            $(".iconchange1").removeClass("hidden");
            $(".search_Bar_item").each(function () {
                var index = $(this).index();
                if (index <= 8) {
                    $(this).removeClass("hidden")
                }

            })
        } else {
            $(".iconchange1").addClass("hidden");
            $(".search_Bar_item").each(function () {
                $(this).removeClass("hidden")
            })
        }

        $(".iconDialogTd").each(function (tr,trItem) {
            var $tr = $(trItem);
            var sizeTd = $tr.find(".showDialogTd").size();
            if(sizeTd>5){
                $tr.find(".iconchangeTd").removeClass("hidden");
                $tr.find(".showDialogTd").each(function (a,aItem) {
                    var $a = $(aItem);
                    if(($a.index()+1)>5){
                        var html = $a.get(0);
                        $a.remove();
                        $tr.find(".popover-content").get(0).append(html);
                        $a.addClass("appendTdA")
                    }
                })

            }else{
                $tr.find(".iconchangeTd").addClass("hidden");
                $tr.find(".showDialogTd").each(function () {
                    $tr.removeClass("hidden");
                })
            }
        })

    }, 10);

    function iconchangeShow(that) {
        if($(that).attr("value")==1){
            $(that).attr("value","0");
            $(".iconchange1 .fa").removeClass("fa-chevron-down").addClass("fa-chevron-up");
            $(".search_Bar_item").each(function () {
                $(this).removeClass("hidden")
            })
        }else{
            $(that).attr("value","1");
            $(".iconchange1 .fa").removeClass("fa-chevron-up").addClass("fa-chevron-down");
            $(".search_Bar_item").each(function () {
                var index = $(this).index();
                if (index <= 8) {
                    $(this).removeClass("hidden")
                }else{
                    $(this).addClass("hidden")
                }

            })
        }

    }
    function iconchangeArrow(that) {
        if($(that).attr("value")==0) {
            $(that).attr("value","1");
            $(that).find(".fa").removeClass("fa-sort-desc").addClass("fa-sort-up");
            $(that).find(".fa").css("top","5px");
            $(that).next().removeClass("hidden");

        }else{
            $(that).attr("value","0");
            $(that).find(".fa").removeClass("fa-sort-up").addClass("fa-sort-desc");
            $(that).find(".fa").css("top","0px");
            $(that).next().addClass("hidden");
        }
    }
</script>
